package com.snailhd.framework.common.mq;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * mq消息 基本对象，方便携带一些附加数据为框架提供数据传输支持
 * @author snailhd
 */
public class BaseMqMsg<T> implements Serializable {

    private T data;

    /**
     * 附件，某些框架发送数据时会跟随一些附加数据
     */
    private Map<String,String> attachment = new HashMap<>();

    public BaseMqMsg(T data) {
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Map<String, String> getAttachment() {
        return attachment;
    }

    public void setAttachment(Map<String, String> attachment) {
        this.attachment = attachment;
    }

    public void putAttachment(String key,String val){
        if(this.attachment == null){
            this.attachment = new HashMap<>(6);
        }
        this.attachment.put(key,val);
    }

}
